<?php
/**
 * $Id: restricted.php 629 2010-07-12 06:04:48Z varun $
 * 
 * This file can not be redistributed to anyone without the permission of Giga Promoters
 * Copyright 2005 - 2008, Giga Promoters
 * 						  608 Aggarwal Cyber Plaza
 *						  Netaji Subhash Place, Delhi - 110034
 *						  www.gigapromoters.com
 * 
 *
 * This is parent of parent class of a controller and should not be edited ever without permission.
 * @version 			$Rev: 629 $
 * @lastModifiedBy		$LastChangedBy: varun $
 * @lastChanged			$Date: 2010-07-12 11:34:48 +0530 (Mon, 12 Jul 2010) $
 * @copyright 			Giga Promoters (www.gigapromoters.com)
 * 
 */

/**
 * Restricted link helper. Useful for output of hidden links on a page, but only visible to specific user types.
 *
 */
class RestrictedHelper extends AppHelper {
	
	var $helpers = array('Html', 'Session');
	
	/**
	 * Outputs link
	 *
	 * @param unknown_type $userTypes
	 * @param unknown_type $title
	 * @param unknown_type $url
	 * @param unknown_type $htmlAttributes
	 * @param unknown_type $confirmMessage
	 * @param unknown_type $escapeTitle
	 * @return unknown
	 */
	function link($userTypes = array('Moderator'), $title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true)
	{
		//pr($this->Session->read('Auth.User.userType'));
		if($userTypes=='*' && $this->Session->read('Auth.User'))
				return  $this->Html->link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle);
		if($userTypes!='*' && (in_array($this->Session->read('Auth.User.userType'), $userTypes)))
			return $this->Html->link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle);
	}
	
	
}
?>